<template>
  <el-main>
<!--      基本信息-->
      <el-form ref="registerForm" :model="registerForm" class="login-form">
        <h3 class="title">商户注册</h3>
        <el-form-item label="联系人姓名">
          <el-input v-model="registerForm.username"></el-input>
        </el-form-item>
        <el-form-item label="手机号">
          <el-input v-model="registerForm.mobile"></el-input>
        </el-form-item>
        <el-form-item label="验证码">
          <el-input v-model="registerForm.code"></el-input>
          <el-button type="primary" @click="getCode">发送验证码</el-button>
        </el-form-item>
        <el-form-item label="请输入密码">
          <el-input v-model="registerForm.password"></el-input>
        </el-form-item>
        <el-form-item label="请再次输入密码">
          <el-input v-model="registerForm.password2"></el-input>
        </el-form-item>
        <el-form-item>
          <el-radio-group v-model="registerForm.type">
            <el-radio :label="0">个人职业房东</el-radio>
            <el-radio :label="1">公司化公寓</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="submitForm('registerForm')">下一步</el-button>
          <el-button @click="resetForm('ruleForm')">重置</el-button>
        </el-form-item>
      </el-form>
<!--      详细信息 -->
      <el-dialog title="详细信息" :visible.sync="dialogFormVisible">
        <el-form ref="form" :model="form" label-width="80px">
          <el-form-item label="商户名称" prop="name">
            <el-input v-model="form.name" placeholder="请输入商户名称" />
          </el-form-item>
          <el-form-item label="公司" prop="corporation">
            <el-input v-model="form.corporation" placeholder="请输入公司" />
          </el-form-item>
          <el-form-item label="省县市"  prop="provinceId">
            <el-cascader
              v-model="value"
              :options="options"
              :props="{ 'value':'regionId','label':'regionName'}"
              @change="handleChange"></el-cascader>
          </el-form-item>
          <el-form-item label="地址" prop="address">
            <el-input v-model="form.address" placeholder="请输入地址" />
          </el-form-item>
<!--          <el-form-item label="状态">
            <el-radio-group v-model="form.status">
              <el-radio :label="1">未审核</el-radio>
              <el-radio :label="2">未审核</el-radio>
              <el-radio :label="3">已审核</el-radio>
            </el-radio-group>
          </el-form-item>-->
          <el-form-item label="营业执照" prop="url">
            <el-input v-model="form.url" placeholder="请输入营业执照" />
          </el-form-item>
          <el-form-item label="统一信征码" prop="zheng">
            <el-input v-model="form.zheng" placeholder="请输入统一信征码" />
          </el-form-item>
          <el-form-item label="头像" prop="headPicture">
            <el-input v-model="form.headPicture" placeholder="请输入头像" />
          </el-form-item>
          <el-form-item label="身份证号" prop="certNum">
            <el-input v-model="form.certNum" placeholder="请输入身份证号" />
          </el-form-item>
          <el-form-item label="身份证正面" prop="certPicture">
            <el-input v-model="form.certPicture" placeholder="请输入身份证正面" />
          </el-form-item>
          <el-form-item label="身份证反面" prop="certPicture2">
            <el-input v-model="form.certPicture2" placeholder="请输入身份证反面" />
          </el-form-item>
          <el-form-item label="手持身份证" prop="certPicture3">
            <el-input v-model="form.certPicture3" placeholder="请输入手持身份证" />
          </el-form-item>
          <el-form-item label="公寓网址" prop="apartmentUrl">
            <el-input v-model="form.apartmentUrl" placeholder="请输入公寓网址" />
          </el-form-item>
          <el-form-item label="客服热线" prop="serviceHotline">
            <el-input v-model="form.serviceHotline" placeholder="请输入客服热线" />
          </el-form-item>
          <el-form-item>
            <el-button type="primary" @click="submitForm2('form')">注册</el-button>
            <el-button @click="resetForm2('form')">重置</el-button>
          </el-form-item>
        </el-form>
      </el-dialog>

  </el-main>
</template>

<script>
import {v4} from 'uuid';
import {addBusiness, addBusiness2, getAllCitys, getCode} from "@/api/business/info";
import {getshi} from "@/api/house/info";
export default {
  name: "add",
  data(){
    return{
      form: {

      },
      registerForm:{
        mobile:null,
        token: v4(),
      },
      value:[],
      options:[],
      dialogFormVisible:false,
    }
  },
  created() {
   this.getOptions();
    console.log()
  },
  methods: {
    getOptions(){
      getAllCitys().then(rep=>{
        this.options=rep.data
      });
    },
    getCode() {
      getCode(this.registerForm).then(rep=>{
        console.log(rep.data)
      })
    },
    submitForm(formName) {
      addBusiness(this.registerForm).then(response => {
        this.msgSuccess("新增成功");
        this.dialogFormVisible=true
      });
    },
    resetForm(formName) {
      this.$refs[formName].resetFields();
    },
    submitForm2(formName) {
      addBusiness2(this.form).then(response => {
        this.msgSuccess("新增成功");
        this.dialogFormVisible=false
        this.$router.push("list")
      });
    },
    resetForm2(formName) {
      this.$refs[formName].resetFields();
    },
    handleChange(value){
      this.form.provinceId=value[0];
      this.form.cityId=value[1];
      this.form.areaId=value[2];
      this.value=value;
      console.log(this.form)
    },
  }
}
</script>

<style rel="stylesheet/scss" lang="scss">
.login-code {
  width: 33%;
  height: 38px;
  float: right;
  img {
    cursor: pointer;
    vertical-align: middle;
  }
}
.login-code-img {
  height: 38px;
}
</style>
